<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type = "text/javascript">
    function checkAll(){
        var hobbies = document.getElementsByTagName("input");
        for(var i = 0;i<hobbies.length;i++){
            hobbies[i].checked = true;
        }
    }
    </script>
</head>
<body>
    <input type = "checkbox" name = "hobby" value = "cpp"/>C++
    <input type = "checkbox" name = "hobby" value = "java"/>Java
    <input type = "checkbox" name = "hobby" value = "js"/>Javascript
    <br/>
    <button onclick = "checkAll()";>全选</button>

</body>
</html>